#ifndef COMB_SAM_MAPPINGPARSER_HPP__
#define COMB_SAM_MAPPINGPARSER_HPP__

#include<string>
#include<vector>
#include<fstream>

#include "util.hpp"
#include "sam.h"

/** A parser for SAM output in color space. */
class SamSequenceMappingParser
{
    public:
        SamSequenceMappingParser(const char *fname, std::map<std::string, std::string> &genomes, unsigned int flag);
        bool next_read(SeqRead &sr);
        bool parse_read();
        ~SamSequenceMappingParser();
        
    private:
        samfile_t *sam_fp;
        bam1_t *read;

        int status;

        int total;
        
        // temp values for Read
        std::string id;
        std::string seq;
        std::vector<int> qual;
        std::vector<MapLoci> map_locs;
        int num;
        std::string qual_str;

        std::string last_id;
        
        // temp values for MapLoci 
        std::string chr_id;
        int chr_pos;
        std::string chr_ref;
        char strand;
        int score;
        std::string cigar;
        std::string mrnm;
        unsigned int mpos;
        unsigned int mapq;
        unsigned int isize;

        uint32_t flag;
        bool first_bad;
        std::string old_seq;
        std::string old_qual_str;

        std::map<std::string, std::string> &genome_seqs;
};

#endif
